<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>118-杨辉三角</title>
	</head>
	<body>
		<script type="text/javascript">
			/**
			 * @param {number} numRows
			 * @return {number[][]}
			 * n行有n+1项
			 *      1
			 *     1 1 
			 *    1 2 1
			 *   1 3 3 1
			 * 
			 */
			var generate = function(numRows) {
			    const ret = [];
			
			    for (let i = 0; i < numRows; i++) {
			        const row = new Array(i + 1).fill(1); // 先都填充为1
			        for (let j = 1; j < row.length - 1; j++) {
			            row[j] = ret[i - 1][j - 1] + ret[i - 1][j];
			        }
			        ret.push(row);
			    }
			    return ret;
			};
			
		</script>
	</body>
</html>
